<template>
	<view class="content">
		<cu-custom bgColor="uerHead1 solid-bottom" :isBack="true" textRight="true" type="1" >
			<block slot="backText" class="titilestyle">{{title}}</block>
			<block slot="right" class="" @click="clickRecord"><text class="text-blod text-blue titilestyle cuIcon-check"></text></block>
		</cu-custom>


		<view class="cu-form-group margin-xs basis-xll padding-lr justify-between solid-bottom" style="background-color: none; " id="search">
			<view class="title"><text class="cuIcon-search"></text></view>
			<input placeholder="请输入学校名称" v-model="schoolName" name="input"></input>
			<view class="" v-if="schoolName.length>0" @click="clear">
				<text class="cuIcon-close"></text>
			</view>

		</view>

		<scroll-view scroll-y="true" :style="{height:swiperHeight+'px'}">


			<view class="basis-xll margin-xs padding-lr flex align-center solid-bottom cu-form-group" v-for="(item,index) in schoolList" :key="index" @click="select(index)">
				{{item.name}}
			</view>




		</scroll-view>


	</view>
</template>

<script>
	export default {

		data() {

			return {
				title: "",
				type:0,
				swiperHeight: 0,
				schoolName: "",
				schoolList: [{
					name: "xx"
				}]

			}
		},
		onLoad(option) {
			
			this.title=option.title;
			this.type=option.type;
		},
		watch:{
			schoolName(val){
				console.log(val);
				this.search();
				
			}
			
		},

		onReady() {
			const query = uni.createSelectorQuery().in(this);
			query.select('#search').boundingClientRect(data => {
				this.getInfo().then((e) => {
					this.swiperHeight = e.screenHeight - (e.custom.top + e.custom.height) - data.height;
				});
			}).exec();

		},
		methods: {
			clear() {
				this.schoolName = "";
			},
			search(val){
				
				let num=parseInt((Math.random()*10));
				console.log(num);
			    let arr=[];
				for(let i=0;i<num;i++){
					let dat={
						name:"这是学校："+i
					}
					
					arr.push(dat);
					
				}
				this.schoolList=arr;
				
				
			    // this.apiRequest('/buyer/followUser', {
			    // 	follow_user_id: follow_user_id
			    // }, 0).then(res => {
			    
			    // 	uni.showToast({
			    // 		title: res.msg,
			    // 		icon: 'none'
			    // 	})
			    // })
				
			},
			select(index){
				let pages = getCurrentPages();
				let beforePage = pages[pages.length - 2];
				beforePage.$vm.backSelect("选择学校"+index);
				uni.navigateBack({
					delta: 1,
					success: function() {
						
					}
					
				});
			}
			
		}



	}
</script>

<style scoped>
.cu-form-group{
	background-color: transparent;
}

</style>
